package com.fashopcosmos.preferencias;

import java.io.IOException;

import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileOutputFormat;
import org.apache.hadoop.mapred.JobClient;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.TextInputFormat;
import org.apache.hadoop.mapred.TextOutputFormat;

import com.fashopcosmos.preferencias.beans.PreferenceCustomerBean;
import com.fashopcosmos.preferencias.mapreduce.PreferenceMap;
import com.fashopcosmos.preferencias.mapreduce.PreferenceReduce;

public class CustomerPreference {

	public static void main(String[] arg){
		try{
			JobConf conf = new JobConf(CustomerPreference.class);
			conf.setJobName("PreferenciaUsuarios");
			conf.setOutputKeyClass(Text.class);
			conf.setOutputValueClass(PreferenceCustomerBean.class);
			//
			conf.setMapperClass(PreferenceMap.class);
			conf.setReducerClass(PreferenceReduce.class);
			conf.setInputFormat(TextInputFormat.class);
			conf.setOutputFormat(TextOutputFormat.class);
			FileInputFormat.setInputPaths(conf, new Path(arg[0]));
			FileOutputFormat.setOutputPath(conf, new Path(arg[1]));			
			JobClient.runJob(conf);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
